package com.gs.synedocket.dialog;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.gs.synedocket.R;

public class ToastDialogUtil {
    private static volatile ToastDialogUtil instance;
    private Toast toast;
    private TextView tv;

    public static ToastDialogUtil getInstance() {
        if (instance == null) {
            synchronized (ToastDialogUtil.class) {
                if (instance == null) {
                    instance = new ToastDialogUtil();
                }
            }
        }
        return instance;
    }

    public void makeText(Context context, int string) {
        makeText(context, context.getString(string));
    }

    public void makeText(Context context, String string) {
        if (toast == null) {
            toast = new Toast(context);
            View view = LayoutInflater.from(context).inflate(R.layout.toast_tv, null);
            tv = view.findViewById(R.id.tv_toast);
            toast.setView(view);
            toast.setDuration(3 * 1000);
        }
        tv.setText(string);
        toast.show();
    }
}
